package com.wiretap.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.wiretap.dao.ContactDao;
import com.wiretap.po.Contact;
import com.wiretap.service.ContactService;
import com.wiretap.util.Pager;

public class ContactServiceImpl implements ContactService {
	private ContactDao contactDao;

	@Override
	public Pager<Contact> getAllContactByPhone(String ownerPhone,
			int currentPage, int pageSize) throws Exception {
		return contactDao.getAllContactByPhone(ownerPhone, currentPage,
				pageSize);
	}

	public void setContactDao(ContactDao contactDao) {
		this.contactDao = contactDao;
	}

	@Override
	public void addContact(String name, String number, String ownerPhone) throws Exception {
		Contact contact = new  Contact();
		contact.setAddDate(new Date());
		contact.setName(name);
		contact.setNumber(number);
		contact.setOwnerPhone(ownerPhone);
		List<Contact> contacts = new ArrayList<Contact>(); 
		contacts.add(contact);
		contactDao.addContact(ownerPhone, contacts);
	}

}
